package com.demo.common.exception;

import lombok.Getter;
import lombok.Setter;
import org.apache.log4j.Logger;

import java.io.Serializable;

/**
 * @Description: BusinessException
 * @Author: ChenXueLi
 * @Date: 2018-10-02 15:25
 */
@SuppressWarnings("serial")
public class BusinessException extends Exception implements Serializable {

    private static Logger logger = Logger.getLogger(BusinessException.class);

    @Getter @Setter private int code;

    @Getter @Setter private String message;

    public BusinessException(String message) {
        super(message);
        this.message = message;
    }

    public BusinessException(int code, String message) {
        super(message);
        this.message = message;
        this.code = code;
    }

    public BusinessException(String message, Exception ex) {
        super(message);
        this.message = message;
        logger.error(message + " | " + ex.getMessage(), ex);
    }




}
